Authenticate User

{ authenticateUser }

Generates an access authentication token for the given user to use the API functions or login to the application.

Method

/API3/authentication/authenticateUser

  • API Section: /API3/authentication
  • API Version: 3.0
  • From Release: 2023.10
  • Usage: REST API and Client SDK libraries. REST APIs via POST actions only.
  • Usage by:
    • Enterprise Admin
    • Domain Admin
    • Pro
    • Analyst
    • Viewer
    • Basic
  • Input Parameters

    Name

    userCredentials

    Object Type

    Description

    The user credential object used to set a user's login settings.

    Output Response

    Successful Result Code

    200

    Response Type

    string

    Description of Response Type

    The response is the security token as a base64 string. It is usually stored in a cookie.

    Notes

    The security token is a string that needs to be embedded in every API call to ensure the API calls are authorized. If saved as a cookie in a web browser, it can be used (for the authenticated user) to auto-login into the application.

    Examples

    Code Snippets

    TypeScript
    Curl
    Java
    C#
    Python
    PHP
    curl -X POST \
     -H "Accept: text/plain,text/plain;charset=utf-8" \
     -H "Content-Type: application/json" \
     "http://Your.Server.URL/API3/authentication/authenticateUser" \
     -d '{
      "password" : "password",
      "domain" : "domain",
      "customData" : "customData",
      "username" : "username"
    }'
    
    import com.pyramidanalytics.*;
    import com.pyramidanalytics.auth.*;
    import com.pyramidanalytics.model.*;
    import com.pyramidanalytics.api.AuthenticationServiceApi;
    
    import java.util.*;
    import java.time.*;
    
    public class AuthenticationServiceApiExample {
        public static void main(String[] args) {
            ApiClient defaultClient = Configuration.getDefaultApiClient();
            defaultClient.setBasePath("http://Your.Server.URL/");
    
            // Create an instance of the API class
            AuthenticationServiceApi apiInstance = new AuthenticationServiceApi();
            // Initialize the userCredentials parameter object for the call
            UserCredentials userCredentials = ; // Create the input object for the operation, type: UserCredentials 
    
            try {
                String result = apiInstance.authenticateUser(userCredentials);
                System.out.println(result);
            } catch (ApiException e) {
                System.err.println("Exception when calling AuthenticationServiceApi#authenticateUser");
                e.printStackTrace();
            }
        }
    }
    
    import * as PyramidAnalyticsWebApi from "com.pyramidanalytics";
    
    // Create an instance of the API class
    const api = new PyramidAnalyticsWebApi.AuthenticationServiceApi("http://Your.Server.URL")
    
    const userCredentials = ; // {UserCredentials} 
    
    api.authenticateUser(userCredentials).then(function(data) {
      console.log('API called successfully. Returned data: ' + data);
    }, function(error) {
      console.error(error);
    });
    
    
    using System;
    using System.Diagnostics;
    using PyramidAnalytics.Sdk.Api;
    using PyramidAnalytics.Sdk.Client;
    using PyramidAnalytics.Sdk.Model;
    
    public class authenticateUserExample
    {
        public static void Main()
        {
            Configuration conf = new Configuration();
            conf.BasePath = "http://Your.Server.URL/";
            
            
            GlobalConfiguration.Instance = conf;
            
            // Create an instance of the API class
            var apiInstance = new AuthenticationServiceApi();
            // Initialize the userCredentials parameter object for the call
            var userCredentials = new UserCredentials(); // UserCredentials | 
    
            try {
                // Generates an access authentication token for the given user to use the API functions or login to the application.
                string result = apiInstance.authenticateUser(userCredentials);
                Debug.WriteLine(result);
            } catch (Exception e) {
                Debug.Print("Exception when calling AuthenticationServiceApi.authenticateUser: " + e.Message );
            }
        }
    }
    
    
    import com.pyramidanalytics
    from com.pyramidanalytics import ApiException
    from com.pyramidanalytics import AuthenticationServiceApi
    from pprint import pprint
    
        api_config = com.pyramidanalytics.Configuration(host = 'http://Your.Server.URL')
    
    with com.pyramidanalytics.ApiClient(api_config) as api_client:
        # Create an instance of the API class
        api_instance = AuthenticationServiceApi(api_client)
        # Initialize the userCredentials parameter object for the call
        userCredentials =  # UserCredentials | 
    
        try:
            # Generates an access authentication token for the given user to use the API functions or login to the application.
            api_response = api_instance.authenticate_user(userCredentials)
            pprint(api_response)
        except ApiException as e:
            print("Exception when calling AuthenticationServiceApi->authenticateUser: %s\n" % e)
    <?php
    require_once(__DIR__ . '/vendor/autoload.php');
    
    OpenAPITools\Client\Configuration::getDefaultConfiguration()->setHost('http://Your.Server.URL');
    
    // Create an instance of the API class
    $api_instance = new OpenAPITools\Client\Api\AuthenticationServiceApi();
    $userCredentials = ; // UserCredentials | 
    
    try {
        $result = $api_instance->authenticateUser($userCredentials);
        print_r($result);
    } catch (Exception $e) {
        echo 'Exception when calling AuthenticationServiceApi->authenticateUser: ', $e->getMessage(), PHP_EOL;
    }
    ?>